//
//  PosRegistViewController.m
//  NewPro
//
//  Created by RYX on 2018/11/26.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "PosRegistViewController.h"
#import "PosRegistCell.h"
#import "POSActivationVC.h"
#import "TraditionPOSVC.h"
#import "MerchantCardChangeViewController.h"


@interface PosRegistViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,copy) NSArray *titlesArr;
@property (nonatomic,copy) NSArray *detailsArr;
@property (nonatomic,copy) NSArray *vcArr;

@end

@implementation PosRegistViewController

- (NSArray *)titlesArr{
    
    if (!_titlesArr) {
        
        _titlesArr = @[@[@"MPOS",@"传统POS"],@[@"商户结算卡更换申请"]];
    }
    
    return _titlesArr;
}

- (NSArray *)detailsArr{
    
    if (!_detailsArr) {
        
        _detailsArr = @[@[@"申请激活",@"申请开通"],@[@"申请更换"]];
    }
    
    return _detailsArr;
}

- (NSArray *)vcArr{
    
    if (!_vcArr) {
        
        _vcArr = @[@[[POSActivationVC class],[TraditionPOSVC class]],@[[MerchantCardChangeViewController class]]];
    }
    
    return _vcArr;
}
//- (void)viewWillAppear:(BOOL)animated{
//
//    [super viewWillAppear:YES];
//    self.navigationController.navigationBar.hidden = YES;
//}
//
//- (void)viewWillDisappear:(BOOL)animated{
//
//    [super viewWillDisappear:YES];
//    self.navigationController.navigationBar.hidden = NO;
//}


- (UITableView *)tableView{
    
    if (!_tableView) {
        
        _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
        _tableView.backgroundColor = [UIColor clearColor];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.sectionFooterHeight = 0.5;
        _tableView.sectionHeaderHeight = 9.5;
        _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0.5)];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
        
    }
    
    return _tableView;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUI];
    
}


- (void)setUI{
    
    [self setNavBarWithTitle:@"商户开通申请"];
    
    [self.view addSubview:self.tableView];
    
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.right.bottom.equalTo(self.view);
        
    }];
    
    [self.tableView.mj_header beginRefreshing];
}


#pragma mark - UITableViewDelegate,UITableViewDataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return [PosRegistCell getHeight];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.titlesArr.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    NSArray *arr = self.titlesArr[section];
    return arr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    PosRegistCell *cell = [PosRegistCell tempWithTableView:tableView];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    cell.title = self.titlesArr[indexPath.section][indexPath.row];
    cell.detail = self.detailsArr[indexPath.section][indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    UIViewController *VC = [[self.vcArr[indexPath.section][indexPath.row] alloc] init];
    [self.navigationController pushViewController:VC animated:YES];
    
}


@end
